package com.baizhi.factory;

/**
 * 罐头生产工厂
 */
public class FruitFactory {
    private Fruit fruit;

    /**
     * 方法：根据水果名称生成对应的水果罐头
     * @param name
     * @return
     */
    public Fruit getFruit(String name){
        if("苹果".equals(name)){
            fruit = new Apple();
        }else if("橘子".equals(name)){
            fruit = new Orange();
        }else if("香蕉".equals(name)){
            fruit = new Banana();
        }

        return fruit;
    }
}
